package com.example.excelgenera.message;

import com.example.excelgenera.controller.Greeting;
import com.example.excelgenera.controller.HelloMessage;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;

@Component
public class GreetingMessage {
    @MessageMapping("/hello")
    @SendTo("/topic/greetings")
    public static Greeting greeting(HelloMessage message) throws Exception {
        Thread.sleep(1000); // simulated delay
        return new Greeting("Hello, " + message.getName() + "!");
    }
}
